#!/bin/bash

# 配置阿里源
yum install wget -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache

# 安装docker
yum remove docker            \
    docker-client            \
    docker-client-latest     \
    docker-common            \
    docker-latest            \
    docker-latest-logrotate  \
    docker-logrotate         \
    docker-engine -y
yum install -y yum-utils
yum-config-manager           \
    --add-repo               \
    https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
systemctl start docker
[ ! -d /etc/docker ] && mkdir /etc/docker
cp conf/daemon.json /etc/docker/daemon.json
systemctl restart docker

# 安装nacos
docker pull nacos/nacos-server
docker run --name nacos -e MODE=standalone -p 8848:8848 -d --restart=always nacos/nacos-server

# 安装redis
docker pull redis
docker run --name redis -p 6379:6379 -d --restart=always redis

# 安装grafana
docker pull grafana/grafana
docker run --name grafana -p 3000:3000 -d --restart=always grafana/grafana

# 安装influxdb
docker pull influxdb:1.8
docker run --name influxdb -p 8086:8086 -d --restart=always influxdb:1.8

# 安装node_exporter
# docker pull linuxkit/node_exporter
# docker run --name node-exporter -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" -d --restart=always linuxkit/node-exporter

# 安装prometheus
# docker pull bitnami/prometheus
# docker run --name prometheus                                                                                      \
    # -v $(cd $(dirname "$0") &> /dev/null && pwd)/conf/prometheus.yml:/opt/bitnami/prometheus/conf/prometheus.yml  \
    # -p 9090:9090 -d --restart=always bitnami/prometheus

# 安装mysql
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
